#include <iostream>
#include <algorithm>
typedef long long LL;
using namespace std;

int days[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool is_leap_year(int year)
{
    return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}

// 暴力法肯定是不行的
// 可以枚举月和天的最小公倍数，然后快速求到满足要求的年份

int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); };

int main()
{
    LL ans = 0;
    for (int i = 1; i <= 12; ++i)
        for (int j = 1; j <= days[i]; ++j)
        {
            // 求出两个数的最小公倍数
            int k = i * j / gcd(i, j);
            int end = 2000000 + (i == 1 && j == 1);
            for (int ii = 1; ii * k < end; ++ii)
                if (i != 2 || i == 2 && j != 29)
                {
                    if (ii * k >= 2000)
                        ++ans;
                }
                else
                {
                    if (ii * k >= 2000 && is_leap_year(ii * k))
                        ++ans;
                }
        }
    cout << ans << endl;
    return 0;
}
